#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_addRow_clicked()
{
    int row = ui->tableWidget->rowCount();
    ui->tableWidget->insertRow(row);
}

void Widget::on_pushButton_deleteRow_clicked()
{
    int row = ui->tableWidget->currentRow();
    if(row<0)
       return;
    ui->tableWidget->removeRow(row);
}

void Widget::on_pushButton_addColumn_clicked()
{
    const QString& s = ui->lineEdit->text();
    int col = ui->tableWidget->columnCount();
    ui->tableWidget->insertColumn(col);
    QTableWidgetItem* item = new QTableWidgetItem();
    item->setText(s);
    ui->tableWidget->setHorizontalHeaderItem(col,item);
}

void Widget::on_pushButton_deleteColumn_clicked()
{
    int col = ui->tableWidget->currentColumn();
    if(col<0)
        return;
    ui->tableWidget->removeColumn(col);
}
